Namespace TAP
    Public Class TAPFile

        Private Const PolkomtelTADIG As String = "POLKM"
        Private Const DirectionRoamingIn As String = "V"
        Private Const DirectionRoamingOut As String = "O"

        Public ReadOnly Name As String
        Public ReadOnly Sender As String
        Public ReadOnly Recipient As String
        Public ReadOnly SequenceNumber As Long

        Public OldestCallTimeStamp As Date
        Public NewestCallTimeStamp As Date
        Public Cutoff As Date
        Public CorrectRecordCount As Long
        Public CorrectSDRNetValue As Decimal
        Public CorrectSDRTaxValue As Decimal
        Public BadRecordCount As Long
        Public BadSDRNetValue As Decimal
        Public BadSDRTaxValue As Decimal
        Public RejectionCode As Integer
        Public RejectionReason As String

        Public ReadOnly Property CorrectSDRValue() As Decimal
            Get
                CorrectSDRValue = CorrectSDRNetValue + CorrectSDRTaxValue
            End Get
        End Property

        Public ReadOnly Property BadSDRValue() As Decimal
            Get
                BadSDRValue = BadSDRNetValue + BadSDRTaxValue
            End Get
        End Property

        Public ReadOnly Property Partner() As String
            Get
                If Sender = PolkomtelTADIG Then
                    Partner = Recipient
                Else
                    Partner = Sender
                End If
            End Get
        End Property

        Public ReadOnly Property Direction() As String
            Get
                If Sender = PolkomtelTADIG Then
                    Direction = DirectionRoamingIn
                Else
                    Direction = DirectionRoamingOut
                End If
            End Get
        End Property

        Public Sub New(ByVal TAPFileName As String)
            If Not ( _
                TAPFileName Like "CDPOLKM?????#####" _
                Or TAPFileName Like "CD?????POLKM#####" _
            ) Then Throw New Exception("Wrong TAPFileName format")

            Name = TAPFileName.ToUpper
            Sender = Name.Substring(2, 5)
            Recipient = Name.Substring(7, 5)
            SequenceNumber = Long.Parse(Name.Substring(12, 5))
        End Sub
    End Class
End Namespace